<?php
include "../../fun.php";
isLogin();
$db=conndb();
$page=isset($_GET["page"])?$_GET["page"]:1;
$limit=isset($_GET["limit"])?$_GET["limit"]:5;
$username=isset($_GET["username"])?$_GET["username"]:'';
$realname=isset($_GET["realname"])?$_GET["realname"]:'';
$where='';
if ($username) {
    $where.="and username like '%{$username}%'";
}
if ($realname) {
    $where.="and realname like '%{$realname}%'";
}
if ($where) {
    $where="where".substr($where,3);
}

$sql_count="select count(*) as count from user {$where}";
$res_count=query1($db,$sql_count,false);
$count=$res_count["count"];
$start=($page-1)*$limit;
$sql="select * from user {$where} order by id desc limit {$start},{$limit}";
$re=query1($db, $sql);
$data=["code"=>0,"msg"=>"操作成功","data"=>$re,"count"=>$count];
echo json_encode($data, JSON_UNESCAPED_UNICODE);

?>